Attribute VB_Name = "Database"
'Copyright (C) 2011, 2012 Biergaizi
'License: GPL v3 or later.
Option Explicit
Public Conn As New ADODB.Connection
Dim Active As Boolean

Public Function Connect(dbpath As String) As Boolean
    On Error GoTo err

    Debug.Assert Active = False
    Conn.CursorLocation = adUseClient
    Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & "'" & dbpath & "'" & ";Persist Security Info=False"
    Active = True
    Connect = True
    
    Debug.Print "Connected to the database!"
Exit Function
err:
    Connect = False
End Function

Public Function Disconnect()
    Conn.Close
    Active = False
    Disconnect = True
End Function
